<template>
  <slot name="default"></slot>
</template>

<script lang="ts" setup>

import {ref, watch} from "vue";
import {useI18n} from 'vue-i18n'
import {ConfigProviderProps} from "../../index";


defineOptions({
  name: 'KiteConfigProvider'
})
let locale;
try {
  const i18n = useI18n()
  locale = i18n.locale
} catch (e) {
  // vue-i18n 不存在时的处理
  locale = ref('zh_cn') // 使用默认语言
}

const props = withDefaults(defineProps<ConfigProviderProps>(), {
  locale: 'zh_cn',
  theme: 'light'
})
watch(() => props.locale, (lang) => {
  locale.value = lang
})
watch(() => props.theme, (theme) => {
  document.documentElement.setAttribute('data-theme', theme);
})
</script>
<style scoped>

</style>